package com.example.hello.client.NavText;

import com.example.hello.BootstrapNavText;
import com.github.gwtbootstrap.client.ui.constants.Alignment;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.AbstractComponentConnector;
import com.vaadin.shared.ui.Connect;

@Connect(BootstrapNavText.class)
public class BootstrapNavTextConnector extends AbstractComponentConnector {

    @Override
    protected Widget createWidget() {
        return GWT.create(VBootstrapNavText.class);
    }

    @Override
    public VBootstrapNavText getWidget() {
        return (VBootstrapNavText) super.getWidget();
    }

    @Override
    public BootstrapNavTextState getState() {
        return (BootstrapNavTextState) super.getState();
    }

    @Override
    public void onStateChanged(StateChangeEvent stateChangeEvent) {
        super.onStateChanged(stateChangeEvent);

        BootstrapNavTextState state = getState();

        VBootstrapNavText navText = getWidget();

        navText.setAlignment(Alignment.valueOf(state.getAlignment()));
        navText.setText(state.getText());
    }

}
